<?php

class TestController extends Zend_Controller_Action {

	private $_flashMessenger = null;
	private $_userAuth = null;

	public function init() {
		// Инит FlashMessenger
		$this->_flashMessenger = $this->_helper->getHelper('FlashMessenger');
		// Инти UserAuth
		$this->_userAuth = $this->_helper->getHelper('UserAuth');
	}
	
	public function indexAction() {
		Zend_Debug::dump($this->_userAuth->has());

		$usersDbTable = new Application_Model_DbTable_Gb();

		$usersDbTable->select();
		$stmt = $usersDbTable->fetchAll();
		$usersList = $stmt->current()->toArray();
		
		Zend_Debug::dump($usersList);

		$row = $stmt->current();

		$result = $row->findManyToManyRowset('Application_Model_DbTable_Users', 'Application_Model_DbTable_UsersToGb', 'Gb');

		$res = $result->toArray();

		Zend_Debug::dump($res);

		$usersMapper = new Application_Model_Mapper_Users();
		$user = $usersMapper->findByLogin('admin');
	}

//	public function indexAction() {
//		$utgDbTable = new Application_Model_DbTable_UsersToGb();
//
//		$select = $utgDbTable->getDefaultAdapter()->select()
//			->from(array('utg'=>'users_to_gb'), array())
//			->joinInner(array('u'=>'users'), 'u.id = utg.user', array('u.login', 'u.fio'))
//			->joinInner(array('g'=>'gb'), 'g.id = utg.gb', array('g.id', 'g.path', 'g.text', 'g.date'))
//			->order('g.path');
//
//		$stmt = $select->query(Zend_Db::FETCH_OBJ);
//
//		Zend_Debug::dump($stmt->fetchAll());
//	}

}